package com.itheima.d3_collection_traverse;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 *       目标：完成电影信息的展示。
 *       new Movie("《肖生克的救赎》" , 9.7 ,  "罗宾斯")
 *       new Movie("《霸王别姬》" , 9.6 ,  "张国荣、张丰毅")
 *       new Movie("《阿甘正传》" , 9.5 ,  "汤姆.汉克斯")
 */
public class CollectionTest04 {
    public static void main(String[] args) {
        Collection<Move> list=new ArrayList<>();
        list.add(new Move("《肖生克的救赎》" , 9.7 ,  "罗宾斯"));
        list.add( new Move("《霸王别姬》" , 9.6 ,  "张国荣、张丰毅"));
        list.add( new Move("《阿甘正传》" , 9.5 ,  "汤姆.汉克斯"));

        Iterator<Move> iterator = list.iterator();
        while (iterator.hasNext()) {
            Move m=iterator.next();
            System.out.println("名字是"+m.getName()+"评分是：" +m.getScore()+"主演是"+m.getActor());
        }

        for(Move m:list){
            System.out.println("名字是"+m.getName()+"评分是：" +m.getScore()+"主演是"+m.getActor());
        }

        list.forEach(m->{ System.out.println("名字是"+m.getName()+"评分是：" +m.getScore()+"主演是"+m.getActor());});
    }
}

class Move{
    private String name;
    private double score;
    private String actor;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getScore() {
        return score;
    }

    public void setScore(double score) {
        this.score = score;
    }

    public String getActor() {
        return actor;
    }

    public void setActor(String actor) {
        this.actor = actor;
    }

    public Move(String name, double score, String actor) {
        this.name = name;
        this.score = score;
        this.actor = actor;
    }
}